/*
 * Copyright 2009 Google Inc.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

package com.google.gwt.gdata.ext.client.youtube;

import com.google.gwt.gdata.client.GDataRequestParameters;
import com.google.gwt.gdata.client.GoogleService;

/**
 * YouTube service.
 */
public class YouTubeService extends GoogleService {
  
  /**
   * Constructs a YouTubeService object.
   * 
   * @param applicationName Name of application (used for tracking).
   * @return A YouTubeService object.
   */
  public static native YouTubeService newInstance(
      String applicationName) /*-{
    return new $wnd.google.gdata.client.GoogleService(applicationName);
  }-*/;

  protected YouTubeService() { }

  /**
   * Deletes a document entry.
   * 
   * @param uri URI of entry.
   * @param callback Callback defining success and failure handlers for this
   * command.
   */
  public final void deleteDocumentEntry(String uri,
      YouTubeVideoEntryCallback callback) {
    this.deleteDocumentEntry(uri, callback);
  }

  /**
   * Retrieves a document entry.
   * 
   * @param uri URI of entry.
   * @param callback Callback defining success and failure handlers for this
   * command.
   */
  public final void getDocumentEntry(String uri,
      YouTubeVideoEntryCallback callback) {
    this.getEntry(uri, callback, YouTubeVideoEntry.getConstructor(), true, null);
  }
  
  /**
   * Retrieves a document entry.
   * 
   * @param uri URI of entry.
   * @param callback Callback defining success and failure handlers for this
   * command.
   * @param parameters The request parameters.
   */
  public final void getDocumentEntry(String uri,
      YouTubeVideoEntryCallback callback, GDataRequestParameters parameters) {
    this.getEntry(uri, callback, YouTubeVideoEntry.getConstructor(), true,
        parameters);
  }

  /**
   * Retrieves the feed of documents.
   * 
   * @param uri URI of feed or query.
   * @param callback Callback defining success and failure handlers for this
   * command.
   */
  public final void getVideoFeed(String uri,
      YouTubeVideoFeedCallback callback) {
    this.getFeed(uri, callback, YouTubeVideoFeed.getConstructor(), true, null);
  }
  
  /**
   * Retrieves the feed of documents.
   * 
   * @param uri URI of feed or query.
   * @param callback Callback defining success and failure handlers for this
   * command.
   * @param parameters The request parameters.
   */
  public final void getDocumentFeed(String uri,
      YouTubeVideoFeedCallback callback, GDataRequestParameters parameters) {
    this.getFeed(uri, callback, YouTubeVideoFeed.getConstructor(), true, parameters);
  }


  /**
   * Inserts a new document entry.
   * 
   * @param uri URI of feed.
   * @param entry Entry to insert.
   * @param callback Callback defining success and failure handlers for this
   * command.
   */
  public final void insertDocumentEntry(String uri, YouTubeVideoEntry entry,
      YouTubeVideoEntryCallback callback) {
    this.insertEntry(uri, entry, callback, YouTubeVideoEntry.getConstructor());
  }
  
  /**
   * Updates a document entry.
   * 
   * @param uri URI of entry.
   * @param entry Entry to update.
   * @param callback Callback defining success and failure handlers for this
   * command.
   */
  public final void updateDocumentEntry(String uri, YouTubeVideoEntry entry,
      YouTubeVideoEntryCallback callback) {
    this.updateEntry(uri, entry, callback,
        YouTubeVideoEntry.getConstructor(), null);
  }
  
  /**
   * Updates a document entry.
   * 
   * @param uri URI of entry.
   * @param entry Entry to update.
   * @param callback Callback defining success and failure handlers for this
   * command.
   * @param parameters The request parameters.
   */
  public final void updateDocumentEntry(String uri, YouTubeVideoEntry entry,
      YouTubeVideoEntryCallback callback, GDataRequestParameters parameters) {
    this.updateEntry(uri, entry, callback, YouTubeVideoEntry.getConstructor(),
        parameters);
  }
  
}